PROJECT(znx C)

CMAKE_MINIMUM_REQUIRED(VERSION 3.7)

# ADD_DEFINITIONS(-DZNX_MEM_NO_POOL)
# ADD_DEFINITIONS(-DZNX_THREAD_MEM_NO_POOL)
# ADD_DEFINITIONS(-DZNX_POOL_NO_PAGE)
ADD_DEFINITIONS(-DZNX_DUMP_MEM_STATUS)

# 编译器选择
SET(CMAKE_C_COMPILER "clang-11")

# 链接选项
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address -rdynamic")

# 编译选项
ADD_COMPILE_OPTIONS(-Wall -Wextra -Werror -Wno-unused-parameter -Wconversion)
ADD_COMPILE_OPTIONS(-march=native -std=gnu11 -ggdb -fstack-protector --param=ssp-buffer-size=4)

IF(BUILD_TYPE STREQUAL "release")
    ADD_COMPILE_OPTIONS(-O2)
ELSEIF(BUILD_TYPE STREQUAL "debug")
    ADD_COMPILE_OPTIONS(-O0)
ELSE()
    ADD_COMPILE_OPTIONS(-fsanitize=address -fno-omit-frame-pointer -O0)
ENDIF()


INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libs/yaml/include/)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/libs/openssl/include/)

LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/libs/openssl/lib/)
LINK_DIRECTORIES(${PROJECT_SOURCE_DIR}/libs/yaml/lib/)

# add modules
SET(MODULES_SRC "")
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/modules)
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/obj)
ADD_SUBDIRECTORY(obj)

MESSAGE(MODULES_SRC ": " ${MODULES_SRC})

ADD_SUBDIRECTORY(src)
ADD_SUBDIRECTORY(test)